import React from "react";
import {Button, Result} from "antd";
import BaseComponent from "../../../../redare/components/BaseComponent";

export class Page404 extends BaseComponent {

    _onBack() {
        let ctx = window._ctxApi;
        if (window._ctxApi === '') {
            ctx = '/';
        }
        window.location.href = ctx;
    }

    render() {
        return (
            <Result
                status="404"
                title="抱歉，您访问的页面不存在或页面已下线！！！"
                extra={<Button type="primary" onClick={this._onBack.bind(this)}>返回</Button>}
            />
        )
    }
}

export class Page403 extends BaseComponent {

    _onBack() {
        let ctx = window._ctxApi;
        if (window._ctxApi === '') {
            ctx = '/';
        }
        window.location.href = ctx;
    }

    render() {
        return (
            <Result
                status="403"
                title="抱歉，您没有权限访问该功能页面！！！"
                extra={<Button type="primary" onClick={this._onBack.bind(this)}>返回</Button>}
            />
        )
    }
}

export class Page500 extends BaseComponent {

    static defaultProps = {
        title: undefined
    };

    _onBack() {
        let ctx = window._ctxApi;
        if (window._ctxApi === '') {
            ctx = '/';
        }
        window.location.href = ctx;
    }

    render() {
        return (
            <Result
                status="500"
                title="500"
                subTitle={this.props.title || '您访问的页面出错了，请稍后访问!'}
                extra={<Button type="primary" onClick={this._onBack.bind(this)}>返回</Button>}
            />
        )
    }
}

